package cn.zhang.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import org.apache.commons.beanutils.Converter;

public class MyDateConverter implements Converter{
	private final static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");//根据传来的时间字符串格式：例如：20130224201210
    public Object convert(Class type, Object value){
       
       if (type.equals(java.util.Date.class) ) {
              try {
                  return format.parse(value.toString());
              } catch (ParseException e) {
                 
                  e.printStackTrace();
                  System.out.println("日期类型转换异常");
              }
       }
       return null;
    }
	
}
